<%@ page import="java.util.Map" %>
<%@ page import="BusinessLogic.ControllerFacade" %>
<%@ page import="Presentation.WebUI.LinksGenerator" %>
<%@ page import="Persistance.SortedList" %>
<%@ page errorPage="error.jsp" %>

<%
	ControllerFacade c = (ControllerFacade)session.getAttribute("c");

    int amount = c.getListLength();
    int start = 0;

    String startParam = request.getParameter("start");
    if (startParam != null)
        start = Integer.parseInt(startParam);
        
%>

<h2>Our movie system recommends the following movies</h2>   	 	 		     
	      
<%
	SortedList<Double,String> list = c.getRecommendation(start);

    String[] show = new String[list.size()];
    int i = 0;
    for(Map.Entry<Double,String> m : list.desendingEntrySet()) {
        show[i] = LinksGenerator.movieLink(m.getValue())+" ("+m.getKey()+")";
        i++;
    }

    String last = "<br />No More Movies<br /><br />";
    out.println(LinksGenerator.showListWithNavButtons(show, request.getParameterMap(), start, amount, last));    
%>

<span class="remark">* number in parethesys is the predicted rate for this movie</span>
